package com.he1618;

import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.stereotype.Service;

@Service
public class MyGaugeService {
    private final Gauge myGauge;

    public MyGaugeService(MeterRegistry registry) {
        this.myGauge = Gauge.builder("my.custom.gauge", this, MyGaugeService::getGaugeValue)
                           .register(registry);
    }

    private double getGaugeValue() {
        // 返回仪表值，可以是任何你希望监控的动态值
        return Math.random() * 100;
    }
}
